package com.fengmi.mq.listener;

import com.fengmi.goods.MallGoods;
import com.fengmi.service.ISearchService;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "fengmi-search-comsumer",
    topic = "goodsToElasticsearch",selectorExpression = "goods",
    consumeMode = ConsumeMode.CONCURRENTLY,
    messageModel = MessageModel.CLUSTERING)
public class ConsumerListener implements RocketMQListener<MallGoods> {
    @Autowired
    private ISearchService searchService;

    public void onMessage(MallGoods mallGoods) {

        //同步索引库
        searchService.goodsToes(mallGoods);

    }
}